//
//  CheckBoxTableViewCell.m
//  test
//
//  Created by Billy on 15/7/8.
//  Copyright (c) 2015年 seven. All rights reserved.
//

#import "CheckBoxTableViewCell.h"


@interface CheckBoxTableViewCell ()

//@property (nonatomic,strong) UIButton *button_enabled;
//@property (nonatomic,strong) UIButton *button_disabled;
//@property (nonatomic,strong) UILabel *label_enabled;
//@property (nonatomic,strong) UILabel *label_disabled;

@end

@implementation CheckBoxTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        [self pageSettingsAndSubviewsCreation];
    }
    
    return self;

}



#pragma mark - SubviewsCreationAndPageSettings

- (void) pageSettingsAndSubviewsCreation {
    
    [self setBackgroundColor:[UIColor whiteColor]];
    
    

    UIButton *button_enabled = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 55, 30)];
    UILabel *label_enabled = [[UILabel alloc] initWithFrame:CGRectMake(button_enabled.frame.origin.x+button_enabled.bounds.size.width+2.0, 0, 40, 30)];
    
    UIButton *button_disabled  = [[UIButton alloc] initWithFrame:CGRectMake(label_enabled.frame.origin.x+label_enabled.bounds.size.width+40.0, 0, 55, 30)];
    
    UILabel *label_disabled = [[UILabel alloc] initWithFrame:CGRectMake(button_disabled.frame.origin.x+button_disabled.bounds.size.width+2.0, 0, 40, 30)];
  
    
    [button_disabled addTarget:self action:@selector(buttonSelectedInCustomBoughtView:) forControlEvents:UIControlEventTouchUpInside];

    [button_enabled addTarget:self action:@selector(buttonSelectedInCustomBoughtView:) forControlEvents:UIControlEventTouchUpInside];
    
    [button_enabled setTag:100];
    [button_disabled setTag:200];
    
    [button_enabled setImage:[UIImage imageNamed:@"框-"] forState:UIControlStateNormal];
    [button_disabled setImage:[UIImage imageNamed:@"框-"] forState:UIControlStateNormal];
    
    
    self.yesLab = [[UILabel alloc]init];
    self.yesLab.text =@"可以";
    self.yesLab.font = [UIFont systemFontOfSize:11];
    self.yesLab.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.yesLab];
    
    self.noLab = [[UILabel alloc]init];
    self.noLab.text =@"不可以";
    self.noLab.font = [UIFont systemFontOfSize:11];
    self.noLab.textAlignment = NSTextAlignmentLeft;
    [self addSubview:self.noLab];

    
    
    [self.contentView addSubview:button_disabled];
    [self.contentView addSubview:button_enabled];
    [self.contentView addSubview:label_disabled];
    [self.contentView addSubview:label_enabled];
    
    [self getStr];
    ////NSLog(@"wocwdwa%@",self.labStr);
    
}





- (void)layoutSubviews {
    
//    [self.label_enabled setText:@"能"];
//    
//    [self.label_disabled setText:@"不能"];
//    
//    [self.button_enabled setImage:[UIImage imageNamed:@"框-"] forState:UIControlStateNormal];
//    [self.button_disabled setImage:[UIImage imageNamed:@"框-"] forState:UIControlStateNormal];
    
    
    

    
}

- (void)didClickButtonAtIndex:(SelectionButton) button atCell:(CheckBoxTableViewCell *)cell andIndex:(NSInteger) index {
    
    
    switch (button) {
        case 0:
            ////NSLog(@"cancel");
            break;
            
        case 1:
            ////NSLog(@"ok!");
            break;
            
        default:
            break;
    }
    
}

- (void) buttonSelectedInCustomBoughtView:(UIButton *) button {
    
    
    
    switch (button.tag) {
            
        case 100:
        {
            [self.delegate didClickButtonAtIndex:SelectionButtonEnabled atCell:self.cell andIndex:self.index];
    

        }
            
            break;
            
        case 200:
        {
            
            
            [self.delegate didClickButtonAtIndex:SelectionButtonDisabled atCell:self.cell andIndex:self.index];
            
            


        }
            break;
            
        default:
            break;
    }
    
    
    
}





- (CheckBoxTableViewCell *)getCell {
    
    return self.cell;
}
-(NSString * )getStr{
    
    return self.labStr;
}
@end
